package com.lambada;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author ZhangYue26
 * @CreationTime 2020/3/30 14:39
 * @Version 1.0.0
 * @Description
 */
public class Test {
    public static void main(String[] args) throws ParseException {
        /*SimpleDateFormat slf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = "2019-03-30 14:59:14";
        Date date1 = slf.parse(time);
        System.out.println("当前时间："+time);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date1);
        calendar.add(Calendar.MONTH, 1);
        Date date2 = calendar.getTime();
        System.out.println("一个月后："+slf.format(date2));*/

        /*int[][] ints = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        for (int i = 0; i < ints.length; i++) {
            for (int i1 = 0; i1 < ints[i].length; i1++) {
                System.out.println(ints[i][i1]);
            }
        }*/


        /*List<String> list = Arrays.asList("abc", "def", "ghi");
        List<Character> result = list.stream().flatMap(value -> {
            char[] chars = value.toCharArray();
            Character[] characters = new Character[chars.length];
            for(int i = 0; i < characters.length; i++){
                characters[i] = chars[i];
            }
            return Stream.of(characters);
        }).collect(Collectors.toList());
        result.forEach(System.out::println);*/

        /*List<Integer> list = Arrays.asList(0, 1, 2, 3);
        double count = list.stream().reduce(0, (acc, item) -> acc + item).doubleValue();
        System.out.println(count);*/

        List<Integer> list = Arrays.asList(0, 1, 2, 3);
        Comparator<Integer> comparator = (o1, o2) -> o1.compareTo(o2);
        System.out.println(list.stream().min(comparator).get());
        System.out.println(list.stream().max(comparator).get());



    }
}
